﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="refunds.aspx.cs" Inherits="refunds" EnableEventValidation="false" %>
<%@ Register TagPrefix="ajax" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
<%@ Register TagPrefix="rp" TagName="RefundPays" Src="~/Controls/RefundPays.ascx" %>

<asp:Content ID="ClassifiersContnet" ContentPlaceHolderID="MainContent" Runat="Server">

    <asp:Panel ID="emptyPanel" runat="server" visible="false">
        <div align="center">
            <h1>Carte de credit</h1>
        </div>
    </asp:Panel>
        
    <asp:UpdatePanel ID="previewPanel" runat="server" Visible="false">
        <ContentTemplate> 
            <rp:RefundPays ID="refundPaysControl" runat="server" OnEntrySelected="RefundsSelecetd_Event" />   
            
            <div class="table">
                <div class="row">
                    <div class="cell">&nbsp;La data:&nbsp;</div> 
                    <div class="cell">&nbsp;Contract #:&nbsp;</div>
                    <div class="cell">&nbsp;Client:&nbsp;</div> 
                    <div class="cell">&nbsp;Curs la acordare:&nbsp;</div>
                    <div class="cell">&nbsp;Curs la achitare:&nbsp;</div>
                    <div class="cell">&nbsp;Suma imprumutata:&nbsp;</div>
                    <div class="cell"><asp:LinkButton ID="mifosID" runat="server" OnClick="mifosID_Click"><<< Mifos >>></asp:LinkButton></div>
                </div>
                <div class="row">
                    <div class="cell">&nbsp;<asp:Label ID="dateNowLabel" runat="server"></asp:Label>&nbsp;</div> 
                    <div class="cell">&nbsp;<asp:Label ID="loanNrLabel" runat="server"></asp:Label>&nbsp;</div>
                    <div class="cell">&nbsp;<asp:Label ID="clientNameLabel" runat="server"></asp:Label>&nbsp;</div> 
                    <div class="cell">&nbsp;<asp:Label ID="loanInitialChangeRateLabel" runat="server"></asp:Label>&nbsp;</div> 
                    <div class="cell">&nbsp;<asp:Label ID="loanRealChangeRate" runat="server"></asp:Label>&nbsp;</div>
                    <div class="cell">&nbsp;<asp:Label ID="sumLoanLabel" runat="server"></asp:Label> in MDL&nbsp;</div>
                </div>
            </div>
            <asp:HiddenField ID="changeRateHiddenField" runat="server" />
            <hr />
            
            <asp:GridView ID="refundsLoanGridView" runat="server" 
                AutoGenerateColumns="False"  
                CssClass="mGrid"
                PagerStyle-CssClass="pgr"
                onrowdatabound="refundsLoanGridView_RowDataBound" 
                onselectedindexchanged="refundsLoanGridView_SelectedIndexChanged" 
                ShowFooter="True">
                <Columns>
                    <asp:BoundField DataField="toogleID" HeaderText="[-/+]" />
                    <asp:BoundField DataField="iterationID" HeaderText="Nr." HtmlEncode="False" ></asp:BoundField>
                    <asp:BoundField DataField="paysID" HeaderText="PaysID" HtmlEncode="False" ></asp:BoundField>
                    <asp:TemplateField HeaderText="Data">
                        <ItemTemplate>
                            <asp:Label ID="dataLabel" runat="server" 
                                Text='<%# ((Eval("Data") != null && Eval("Data") is DateTime) ?  ((DateTime)Eval("Data")).ToString(Constants.Constants.ISODateBackwardDotsFormat) : "") %>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="totalLabel" runat="server" Text="Total :" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalPaysLabel" runat="server" Text="Incasat :" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalDiffLabel" runat="server" Text="Rest :" CssClass="tableFooter"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>
                                                
                    <asp:TemplateField  HeaderText="Rata Imprumutului" >
                        <ItemTemplate>                        
                            <asp:Label ID="rateAmountLabel" runat="server" Text='<%# Bind("main") %>'></asp:Label> 
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="totalRateAmountLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalRatePaysLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalRateDiffLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>      
                                                                
                    <asp:TemplateField  HeaderText="Dobinda" >
                        <ItemTemplate>                        
                            <asp:Label ID="percentAmountLabel" runat="server" Text='<%# Bind("profit") %>'></asp:Label> 
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="totalPercentAmountLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalPercentPaysLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalPercentDiffLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>
                     
                    <asp:TemplateField  HeaderText="Penalitatea" >
                        <ItemTemplate>                        
                            <asp:Label ID="penaltyLabel" runat="server" Text='<%# Bind("penalty") %>'></asp:Label> 
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="totalPenaltyLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalPenaltyPaysLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalPenaltyDiffLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField  HeaderText="Corectia la curs" >
                        <ItemTemplate>                        
                            <asp:Label ID="rateCorrectionLabel" runat="server" Text='0'></asp:Label> 
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="totalRateCorrectionLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalRateCorrectionPaysLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalRateCorrectionDiffLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField  HeaderText="Comision ad." >
                        <ItemTemplate>                        
                            <asp:Label ID="comisionAdmLabel" runat="server" Text='<%# Bind("commission") %>'></asp:Label> 
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="totalCommissionAdmLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalCommissionPaysLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalCommissionDiffLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>                                

                    <asp:TemplateField  HeaderText="Total, lei" >
                        <ItemTemplate>                        
                            <asp:Label ID="totalAmountLabel" runat="server" Text='<%# Bind("totalByIteration") %>'></asp:Label>
                            <asp:HiddenField ID="finishedLabel" runat="server" Value='<%# Bind("isFinis") %>' />
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="totalTotalAmountLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalTotalPaysLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                            <br />
                            <asp:Label ID="totalTotalDiffLabel" runat="server" Text="0" CssClass="tableFooter"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>
               
                    <asp:BoundField DataField="currenty" Visible="True" HeaderText="Curs." ControlStyle-Width="0px" FooterStyle-Width="0px" HeaderStyle-Width="0px" ItemStyle-Width="0px" />
                </Columns>
            </asp:GridView>
   
       </ContentTemplate>
    </asp:UpdatePanel>
    <script type="text/javascript">
            function toggleRow(tdID) {
            var element = document.getElementById(tdID);
            var rowID = element.parentNode;

            var tTableID = "MainContent_refundsLoanGridView";
            var tableObject = document.getElementById(tTableID);
            var tableBody = tableObject.getElementsByTagName("tbody")[0]; 
            //alert(tableBody.rows.length);
            var itemValue = parseFloat((tableBody.rows[rowID.rowIndex].cells[1].innerHTML));
            //alert(itemValue);
            var howManyRows = tableBody.rows.length;
            //alert(howManyRows);
            var bExpand = '';
            for (var i = 0; i < howManyRows; i++) {               
                
                var thisTrParent = tableBody.rows[i].cells[2];
                //alert(thisTrParent.innerHTML);

                if (parseFloat(thisTrParent.innerHTML) != 0) {
                    var thisTrElem = tableBody.rows[i].cells[1];
                    var thisNumber = parseFloat(thisTrElem.innerHTML);
                    
                    if (!isNaN(thisNumber))
                        if (thisNumber == itemValue) {
                           // alert(thisNumber);
                            var tr = document.getElementById(tableBody.rows[i].cells[0].parentNode.id);
                            if (tr == null) { return; }
                            var bExpand = tr.style.display == '';
                            tr.style.display = (bExpand ? 'none' : '');
                        }
                }
            }

            if (!bExpand) element.innerHTML = '-';
            else element.innerHTML = '+';
        }
            function toggleRowFinis(tdID) {
                var element = document.getElementById(tdID);
                var rowID = element.parentNode;

                var tTableID = "MainContent_refundsFinisGridView";
                var tableObject = document.getElementById(tTableID);
                var tableBody = tableObject.getElementsByTagName("tbody")[0];
                //alert(tableBody.rows.length);
                var itemValue = parseFloat((tableBody.rows[rowID.rowIndex].cells[1].innerHTML));
                //alert(itemValue);
                var howManyRows = tableBody.rows.length;
                //alert(howManyRows);
                var bExpand = '';
                for (var i = 0; i < howManyRows; i++) {

                    var thisTrParent = tableBody.rows[i].cells[2];
                    //alert(thisTrParent.innerHTML);

                    if (parseFloat(thisTrParent.innerHTML) != 0) {
                        var thisTrElem = tableBody.rows[i].cells[1];
                        var thisNumber = parseFloat(thisTrElem.innerHTML);

                        if (!isNaN(thisNumber))
                            if (thisNumber == itemValue) {
                                // alert(thisNumber);
                                var tr = document.getElementById(tableBody.rows[i].cells[0].parentNode.id);
                                if (tr == null) { return; }
                                var bExpand = tr.style.display == '';
                                tr.style.display = (bExpand ? 'none' : '');
                            }
                    }
                }

                if (!bExpand) element.innerHTML = '-';
                else element.innerHTML = '+';
            }
</script>
<style type="text/css">
tr td:first-child {
    /* styles */
    text-align: center;
    font: bold 12pt/10pt Verdana;
}

    tr {
        cursor: pointer;
    }

    .parentRowPlus {
        /*
          background-color: #d8ebcb;  
        */
        background-color: #ccff99;
    }

    .parentRowMinus {
        /*
            background-color: #e1eff8;
         */
        background-color: #ffcc00;
    }

    tr:hover {
        background-color: #ffeeca;
    }
    .cell {
        border-right: 1px groove orange;}
</style>
</asp:Content>



